<%@ page language="java" import="java.util.*, java.text.*,java.sql.Timestamp,com.zjut.zs.util.tools.*,com.zjut.an.util.tools.*,com.zjut.an.util.system.*,
com.zjut.zs.user.manager.*, com.zjut.zs.user.dao.*,com.zjut.zs.zxlb.manager.*, com.zjut.zs.zxlb.dao.*,com.zjut.zs.school.manager.*, com.zjut.zs.school.dao.*,
com.zjut.zs.userstatus.manager.*, com.zjut.zs.userstatus.dao.*,com.zjut.an.config.manager.*, com.zjut.an.config.dao.*" pageEncoding="utf-8"%>
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">  
<meta name="renderer" content="webkit"> 
<title>专项类别填写 - 招生报名系统</title>
<link rel="stylesheet" href="js/pop/my_popup.css">
<script src="css/tailwindcss.css"></script>
<script type="text/javascript" src="../plugins/assets/plugins/jquery-3.5.1.min.js"></script>
<script src="<%=request.getContextPath() %>/plugins/webupload/plugin/ueditor/third-party/webuploader/webuploader.min.js"></script>
<script type="text/javascript" src="js/pop/my_popup.js"></script>
<style type="text/css">
    body { font-family: 'Noto Sans SC', sans-serif; background-color: #f8fafc; }
    .select1 {
        border:1px solid #ccc;
        padding:8px;
        width:200px;
    }
    #zxtable td{
        height:30px;
        border:1px solid #ccc;
    }
    .input-focus {
        transition: all 0.3s ease;
    }
    .input-focus:focus {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
    }
    .card {
        transition: all 0.3s ease;
    }
    .card:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    }
</style>
</head>

<body>
<jsp:include page="zs_uservalidate.jsp" flush="true"/>
<%
if (session.getAttribute("zsUser") == null&&session.getAttribute("admin") == null&&session.getAttribute("user") == null) {
	out.print("<script>alert('由于长时间未操作，系统已经自动注销，请重新登陆');</script>");
	out.print("<script>top.window.location='main.jsp';</script>");
} else {
ZsSchoolManager zsManager = (ZsSchoolManager) SpringContextUtil.getBean("ZsSchoolManager");
ZsSchool school = new ZsSchool();
school = (ZsSchool)zsManager.getDataByInstance(1,1,null,null,school).getObjects().get(0);

AnConfigManager anconfig = (AnConfigManager) SpringContextUtil.getBean("AnConfigManager");
ZsHTMLCreat html = (ZsHTMLCreat) SpringContextUtil.getBean("ZsHTMLCreat");
ZsZxlbManager xmanager = (ZsZxlbManager) SpringContextUtil.getBean("ZsZxlbManager");
ZsUserManager umanager = (ZsUserManager) SpringContextUtil.getBean("ZsUserManager");
ZsUserStatusManager smanager = (ZsUserStatusManager) SpringContextUtil.getBean("ZsUserStatusManager");
ZsZxlb zxlb = new ZsZxlb();
ZsUser user = null;
if((session.getAttribute("admin")!=null||session.getAttribute("user")!=null) && request.getParameter("usId")!=null) {
	String usId = request.getParameter("usId");
	user = umanager.getData(usId);
} else if (session.getAttribute("zsUser")!=null) {
	user = (ZsUser)session.getAttribute("zsUser");
}
String url = "&usId="+user.getUsId();
List list = new ArrayList();
if (user!=null) {
	zxlb.setZsUser(user);
	list = xmanager.getDataByInstance(1,100,"zxId","asc",zxlb).getObjects();
}
if(request.getParameter("zxId")!=null) {
	zxlb = xmanager.getData(request.getParameter("zxId"));
}
ZsUserStatus userStatus = smanager.getDataByUser(user);
boolean edit=false;//允许编辑
//未确认，被退回允许编辑
if(Status.APPSTATUS_NULL.getStatus().equals(userStatus.getAppStatus()) || Status.APPSTATUS_NO.getStatus().equals(userStatus.getAppStatus()) || Status.APPSTATUS_NOTIME.getStatus().equals(userStatus.getAppStatus()))edit=true;
//如果材料填写截止或报考信息填写截止，不允许编辑
if(!Status.ON.getStatus().equals(school.getScAppActive()) || !Status.ON.getStatus().equals(school.getScZxlbActive()) )edit=false;
 %>


    <div class="max-w-6xl mx-auto px-4 py-8">
        <!-- 现有数据表格 -->
        <div class="card bg-white rounded-xl shadow-sm p-6 mb-6">
            <h2 class="text-lg font-semibold text-gray-900 mb-4 flex items-center">
                <svg class="w-5 h-5 text-blue-600 mr-2" fill="currentColor" viewBox="0 0 20 20">
                    <path fill-rule="evenodd" d="M3 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm0 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm0 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm0 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z" clip-rule="evenodd"/>
                </svg>
                现有专项信息
            </h2>

            <div class="overflow-x-auto">
                <table class="min-w-full bg-white border border-gray-200 rounded-lg">
                    <thead class="bg-gray-50">
                        <tr>
                            <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">专项类别</th>
                            <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">奖项名称</th>
                            <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">奖项级别</th>
                            <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">获奖时间</th>
                            <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">组织单位</th>
                            <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">获奖等级</th>
                            <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">操作</th>
                        </tr>
                    </thead>
                    <tbody class="divide-y divide-gray-200">
                        <%
                        for (int i=0; i<list.size(); i++){
                            ZsZxlb obj = (ZsZxlb)list.get(i);
                            if(!"获奖情况".equals(obj.getZxType())){
                        %>
                        <tr class="hover:bg-gray-50 transition-colors">
                            <td class="px-4 py-3 text-sm text-gray-900"><%=obj.getZxType() %></td>
                            <td class="px-4 py-3 text-sm text-gray-900"><%=obj.getZxName() %></td>
                            <td class="px-4 py-3 text-sm text-gray-900"><%=obj.getZxJb() %></td>
                            <td class="px-4 py-3 text-sm text-gray-900"><%=obj.getZxDate() %></td>
                            <td class="px-4 py-3 text-sm text-gray-900"><%=obj.getZxOrg() %></td>
                            <td class="px-4 py-3 text-sm text-gray-900"><%=obj.getZxDj() %></td>
                            <td class="px-4 py-3 text-sm">
                                <%if(edit){ %>
                                <div class="flex space-x-2">
                                    <a href="zs_zxlb.jsp?zxId=<%=obj.getZxId() %><%=url %>" class="text-blue-600 hover:text-blue-800 transition-colors">编辑</a>
                                    <span class="text-gray-300">|</span>
                                    <a href="#" onclick="javascript:deleteobj('<%=obj.getZxId() %>');" class="text-red-600 hover:text-red-800 transition-colors">删除</a>
                                </div>
                                <%} %>
                            </td>
                        </tr>
                        <%}
                        }%>
                    </tbody>
                </table>
            </div>
        </div>
    					<%if(edit){ %>
                        <!-- 新增/编辑表单 -->
                        <div class="card bg-white rounded-xl shadow-sm p-6 mb-6">
                            <h2 class="text-lg font-semibold text-gray-900 mb-4 flex items-center">
                                <svg class="w-5 h-5 text-blue-600 mr-2" fill="currentColor" viewBox="0 0 20 20">
                                    <path fill-rule="evenodd" d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z" clip-rule="evenodd"/>
                                </svg>
                                <%=zxlb.getZxId()==null?"新增":"编辑" %>专项信息
                            </h2>

                            <form id="ff" name="add" role="form" class="form-horizontal" action="" method="post">
                                <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 mb-6">
                                    <div class="space-y-2">
                                        <label class="block text-sm font-medium text-gray-700">专项类别</label>
                                        <input id="zxType" name="zxType" type="text"
                                               class="input-focus w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-gray-100 cursor-pointer"
                                               value="<%=html.getInputString(zxlb.getZxType()) %>" required readonly onclick="oTwoPopup.show();"
                                               placeholder="点击选择专项类别" />
                                    </div>
                                    <div class="space-y-2">
                                        <label class="block text-sm font-medium text-gray-700">奖项名称</label>
                                        <input id="zxName" name="zxName" type="text"
                                               class="input-focus w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-gray-100 cursor-pointer"
                                               value="<%=html.getInputString(zxlb.getZxName()) %>" required readonly onclick="oTwoPopup.show();"
                                               placeholder="点击选择奖项名称" />
                                    </div>
                                    <div class="space-y-2">
                                        <label class="block text-sm font-medium text-gray-700">奖项级别</label>
                                        <input id="zxJb" name="zxJb" type="text"
                                               class="input-focus w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
                                               value="<%=html.getInputString(zxlb.getZxJb()) %>" required
                                               placeholder="请输入奖项级别" maxlength="50" />
                                    </div>
                                    <div class="space-y-2">
                                        <label class="block text-sm font-medium text-gray-700">获奖时间</label>
                                        <div class="relative">
                                            <input id="zxDate" name="zxDate" type="text"
                                                   class="input-focus w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
                                                   value="<%=html.getInputString(zxlb.getZxDate()) %>" required
                                                   placeholder="请选择获奖时间" onfocus="laydate({elem: this})" />
                                            <div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none">
                                                <svg class="w-5 h-5 text-gray-400" fill="currentColor" viewBox="0 0 20 20">
                                                    <path fill-rule="evenodd" d="M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z" clip-rule="evenodd"/>
                                                </svg>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="space-y-2">
                                        <label class="block text-sm font-medium text-gray-700">组织单位</label>
                                        <input id="zxOrg" name="zxOrg" type="text"
                                               class="input-focus w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
                                               value="<%=html.getInputString(zxlb.getZxOrg()) %>" required
                                               placeholder="请输入组织单位" maxlength="100" />
                                    </div>
                                    <div class="space-y-2">
                                        <label class="block text-sm font-medium text-gray-700">获奖等级</label>
                                        <input id="zxDj" name="zxDj" type="text"
                                               class="input-focus w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
                                               value="<%=html.getInputString(zxlb.getZxDj()) %>" required
                                               placeholder="请输入获奖等级" maxlength="50" />
                                    </div>
                                </div>

                                <input name="zxFiles" type="text" id="zxFiles" value="<%=html.getInputString(zxlb.getZxFiles()) %>" class="hidden" />
                                <input id="zxId" name="zxId" type="text" class="hidden" value="<%if(null==zxlb.getZxId()){out.print("");}else{out.print(zxlb.getZxId());}; %>" />
                                <input id="zsUser.usId" name="zsUser.usId" type="text" class="hidden" value="<%=zxlb.getZsUser().getUsId()%>" />

                                <div class="text-right">
                                    <button type="submit" class="px-6 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors duration-200 font-medium">
                                        确认保存
                                    </button>
                                </div>
                            </form>
                        </div>

					<div class="my-popup two-popup" id="twoPopup" style="clear:both;display:none">
					  <div class="popup-content">
					    <p class="msg">专项类别选择</p><button id="closeBtn" style="float:right;">关闭</button>
					    <div class="btn-box">
					    <table width="800" id="zxtable">
					    <td>专项类别</td><td>奖项名称</td><td>选择</td>
					    <%
					    List jlist = anconfig.getConfigsInfoByClass("专项类别明细");
					    for (int i=0;i<jlist.size(); i++) {
					    	AnConfig c = (AnConfig)jlist.get(i);
					    	%>
					    	<tr onclick="addzx('<%=c.getCoName()%>','<%=c.getCoValue()%>')" onmouseover="this.bgColor='#ccc'" onmouseout="this.bgColor=''"><td><%=c.getCoName() %></td><td><%=c.getCoValue() %></td><td><a href="#" onclick ="addzx('<%=c.getCoName()%>','<%=c.getCoValue()%>')"/>选择</a></td></tr>
					    	<%
					    }
					    %>
					    </table>
					      </div>
					  </div>
					</div>
		<script src="js/laydate.dev.js" type="text/javascript"></script>
		<script type="text/javascript">
			//////////////////////////////////////////
			var closeBtn = document.getElementById('closeBtn');
			var oTwoPopup = new MyPopup('twoPopup', {
			  param: {
			    isfixed: false,	// 弹窗是否固定居中（默认true可以） 值：true、false
			    bgclose: false,	// 可否通过点击背景关闭弹窗 （默认true可以） 值：true、false
			    type: 'top',	// 弹窗出现的方式（默认none无动画） 值：none、opacity、top、right、bottom、left
			    time: 400,		// 弹窗出现动画的时长（默认200ms）
			    bgcolor: '#777',// 背景颜色（默认transparent）
			    opacity: 0.2 	// 背景透明度（默认0）
			  },
			  show: function () {
				console.log("这是显示弹窗前调用的函数");
			  },
			  close: function () {
				console.log("这是默认的关闭弹窗前调用的函数");
			  }
			});
			closeBtn.onclick = function () {
				oTwoPopup.close();
			}
			/////////////////////////////////////
			laydate({
				elem: document.getElementById("zxDate")
			});

			function addzx(name,value) {
				$("#zxType").val(name);
				$("#zxName").val(value);
				oTwoPopup.close();
			}
		</script>
		    			<%} %>
    <!-- 填写需知 -->
    <div class="max-w-6xl mx-auto px-4 mb-8">
        <div class="bg-blue-50 border border-blue-200 rounded-lg p-6">
            <h3 class="text-lg font-semibold text-blue-900 mb-3 flex items-center">
                <svg class="w-5 h-5 text-blue-600 mr-2" fill="currentColor" viewBox="0 0 20 20">
                    <path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd"/>
                </svg>
                填写说明
            </h3>
            <div class="text-blue-800 text-sm"><%out.print(anconfig.getSingleConfigInfoByName("专项类别填写需知")); %></div>
        </div>
    </div>
</div>


<script src="../plugins/assets/plugins/jquery-3.5.1.min.js" type="text/javascript"></script>
<script src="../plugins/assets/plugins/jquery-validation/dist/jquery.validate.js" type="text/javascript"></script>
<script src="../plugins/assets/plugins/jquery-validation/dist/jquery.metadata.js" type="text/javascript"></script>
<script src="../plugins/assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js" type="text/javascript" charset="UTF-8"></script>
<script src="../plugins/assets/plugins/bootstrap-datepicker/js/locales/bootstrap-datepicker.zh-CN.js" type="text/javascript"  charset="UTF-8"></script>
<script src="js/formvalidate.js" type="text/javascript"></script>
<script src="../admin/js/publicManager.js" type="text/javascript" charset="utf-8"></script>

		<script type="text/javascript">

		var updateOneAction = '../zsZxlbSave.action?randnum='+Math.floor(Math.random()*1000000);
		var loactionurl = 'zs_zxlb.jsp?<%=url%>';

		$(function(){
		    //jquery.validate
			$("#ff").validate({
				submitHandler: function() {
					//验证通过后 的js代码写在这里

					submitFormAdvance();
				}
			})
		})

		$('.imgtable tbody tr:odd').addClass('odd');


		function deleteobj(zxId) {
			if (confirm("是否确认"))  { 
				$.get("../zsZxlbDelete.action?randnum="+Math.floor(Math.random()*1000000)+"&zxId="+zxId, function(data){
					if(data.flag=="success"){
						alert("删除成功！");
						window.location = loactionurl;
					}else{
						alert("删除失败！");
					}
				}); 
			}
		}
		</script>
<%//} 
}%>		
</body>

</html>
